package net.sf.rose.jdbc.bean;

/**
 * 数据库表字段缓存
 * @author fengjian
 * @since 2014-6-25
 */
public class FieldBean {

	public static String TIMESTAMP = "java.sql.Timestamp";
	public static String DATE = "java.util.Date";
	public static String STRING = "java.lang.String";
	
	/** 表名称 */
	private String table = null;

	/** 字段名称 */
	private String field = null;

	/** Java类型 */
	private String javaType = null;

	public String getTable() {
		return table;
	}

	public void setTable(String table) {
		this.table = table;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public String getJavaType() {
		return javaType;
	}

	public void setJavaType(String javaType) {
		this.javaType = javaType;
	}

	public boolean isDateType() {
		return this.javaType.equals(DATE) || this.javaType.equals(TIMESTAMP) ? true : false;
	}

	public boolean isStringType() {
		return this.javaType.equals(STRING) ? true : false;
	}

	public boolean isNumberType() {
		return this.javaType.equals("java.lang.Integer") || this.javaType.equals("java.math.BigDecimal") ? true : false;
	}

	public String toString() {
		return field + ':' + javaType;
	}
	
	public FieldBean clone() {
		FieldBean field = new FieldBean();
		field.field = this.field;
		field.javaType = this.javaType;
		field.table = this.table;
		return field;
	}
}
